﻿
using System.Reactive.Linq;
#if AVALONIA


namespace KinonekoSoftware.Foundation.UI.Controls
{
    public partial class ForestTextBoxBase
    {
        public static readonly DirectProperty<ForestTextBoxBase, bool> HasTextProperty;

        static ForestTextBoxBase()
        {
            HasTextProperty = AvaloniaProperty.RegisterDirect<ForestTextBoxBase, bool>(nameof(HasText), x => x.HasText);
            TextProperty.Changed.AddClassHandler<ForestTextBoxBase>((x, v) =>
            {

                x.HasText = !string.IsNullOrEmpty(v.GetNewValue<string>());
                x.OnTextChanged();
            });
        }

        private bool _hasText;

        protected virtual void OnTextChanged()
        {
            
        }


        public bool HasText
        {
            get => _hasText;
            set => SetAndRaise(HasTextProperty, ref _hasText, value);
        }
    }
}

#endif